/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.proyecto;

import com.EjercicioTarea.procesos.varios;
import com.proyecto.datos.EntityCatedratico;
import com.proyecto.datos.EntityHorario;
import com.proyecto.datos.EntityHorarioLab;
import com.proyecto.datos.EntityMateria;
import com.proyecto.datos.EntityNota;
import com.proyecto.datos.EntityPlan;
import com.proyecto.modelado.Catedratico;
import com.proyecto.modelado.DetalleHorarioLab;
import com.proyecto.modelado.Horario;
import com.proyecto.modelado.Materia;
import com.proyecto.modelado.Nota;
import com.proyecto.modelado.Plan;
import java.util.ArrayList;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author mario
 */
public class frmInsertarNotaIntroFisica2 extends javax.swing.JInternalFrame {

    ArrayList arry;
    ArrayList arryCate;
    ArrayList arryHora;
    ArrayList arry_5;
    EntityHorario entHora;
    Horario hora;
    EntityCatedratico entCate;
    Catedratico cate;
    EntityHorarioLab entHorLab;
    EntityNota entNota;
    Nota nota;
    DetalleHorarioLab detalhor;
    int id_grupo;
    varios v;
    
    Plan pla;
    EntityPlan entPla;
    int id_plan;
    int id_plan2;
    Materia mate;
    EntityMateria entMate;
    int id_materia;
    int id_materia2;

    //BLOQUEANDO CONTROLES
    public void BloquearControles() {

        this.txtNombres.setText("Nombres");
        this.txtApellidos.setText("Apellidos");
        this.txtInstructor.setText("Instructor");
        this.txtHorarioLab.setText("Horario");
        this.txtID.setText("ID");

        this.txtNombres.setEnabled(false);
        this.txtID.setEnabled(false);
        this.txtApellidos.setEnabled(false);
        this.txtDis1.setEnabled(false);
        this.txtLab1.setEnabled(false);
        this.txtHorarioLab.setEnabled(false);
        this.txtInstructor.setEnabled(false);
    }

    public void HabilitarControles() {

        this.txtDis1.setEnabled(true);
        this.txtLab1.setEnabled(true);

    }

    //cargando txtInstructor
    public void CargarInstructor(int id_grupo, int id_materia) {

        arryCate = new ArrayList();
        cate = new Catedratico();
        try {
            arryCate = cate.MostrarCatexGrupo_U1(id_grupo,id_materia);

            if (arryCate != null) {
                for (int i = 0; i < arryCate.size(); i++) {
                    entCate = (EntityCatedratico) arryCate.get(i);
                }
            }
            this.txtInstructor.setText(entCate.getNombre().concat(" ").concat(entCate.getApellido()));

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(rootPane, ex.toString());
        }
    }

    public void CargarHorarioTxt(int id_grupo, int id_materia) {

        arryHora = new ArrayList();
        hora = new Horario();
        try {
            arryHora = hora.MostrarHorarioxGrupo_U1(id_grupo,id_materia);

            if (arryHora != null) {
                for (int i = 0; i < arryHora.size(); i++) {
                    entHora = (EntityHorario) arryHora.get(i);
                }
            }
            this.txtHorarioLab.setText(entHora.getHorario());

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(rootPane, ex.toString());
        }
    }

    //cargando combobox!
    public void CargarComboBox(int id_materia) {

        arry = new ArrayList();
        detalhor = new DetalleHorarioLab();

        try {
            JList list = new JList();
            DefaultListModel list_model = new DefaultListModel();
            arry = detalhor.ObtenerGrupos_U1(id_materia);
            list_model.addElement("Seleccione");
            if (arry != null) {
                for (int i = 0; i < arry.size(); i++) {
                    entHorLab = (EntityHorarioLab) arry.get(i);
                    list_model.addElement(entHorLab.getEntGrupo());

                }
            } else {
                JOptionPane.showMessageDialog(rootPane, "No se recuperaron datos del combo box", "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);
            }

            list.setModel(list_model);
            this.jcmbGrupo.setModel(new DefaultComboBoxModel(list_model.toArray()));
            this.jcmbGrupo.setSelectedIndex(0);

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(rootPane, ex.toString());
        }

    }

    public void PopularTabla(int id_grupo, int id_materia1, int id_materia2) {
        v = new varios();
        DefaultTableModel tabla;
        Object[] fila = new Object[8];
        try {
            String[] columName = {"ID", "Carnet", "Nombres", "Apellidos", "Cod_Mate", "Lab 2", "Dis 2", "Prom"};
            tabla = new DefaultTableModel(null, columName);
            //populamos el arraylist de la tabla
            arry_5 = new ArrayList();
            nota = new Nota();
            entNota = new EntityNota();

            arry_5 = nota.NotasIntroUnidad1(id_grupo, id_materia1, id_materia2);
            if (arry_5 != null) {



                for (int i = 0; i < arry_5.size(); i++) {
                    entNota = (EntityNota) arry_5.get(i);
                    fila[0] = entNota.getId_nota();
                    fila[1] = entNota.getEntCarnet();
                    fila[2] = entNota.getEntNombre();
                    fila[3] = entNota.getEntApellido();
                    fila[4] = entNota.getEntCod_Materia();
                    fila[5] = entNota.getLab2();
                    fila[6] = entNota.getDiscusion2();
                    fila[7] = v.formatearDecimales(entNota.getProm2());
                    tabla.addRow(fila);
                }

                this.jtbleInsertarNotas.setModel(tabla);

                fila[0] = "Total alumnos";
                fila[1] = "";
                fila[2] = "";
                fila[3] = "";
                fila[4] = "";
                fila[5] = "";
                fila[6] = "";
                fila[7] = tabla.getRowCount();
                tabla.addRow(fila);

            } else {
                JOptionPane.showMessageDialog(rootPane, "No se recuperaron datos de la base de datos", "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(rootPane, ex.toString());
        }

    }
    
    //PASA COMO PARAMETRO EL DATO A BUSCAR Y EL ID DEL GRUPO SELECCIONADO EN EL COMBO
    public void Busqueda(String dato) {
        v = new varios();
        DefaultTableModel tabla;
        Object[] fila = new Object[8];
        try {
            String[] columName = {"ID", "Carnet", "Nombres", "Apellidos", "Cod_Mate", "Lab 2", "Dis 2", "Prom"};
            tabla = new DefaultTableModel(null, columName);
            //populamos el arraylist de la tabla
            arry_5 = new ArrayList();
            nota = new Nota();
            entNota = new EntityNota();

            arry_5 = nota.BuscarAlumno(id_grupo,dato,id_materia,id_materia2);
            if (arry_5 != null) {

                for (int i = 0; i < arry_5.size(); i++) {
                    entNota = (EntityNota) arry_5.get(i);
                    fila[0] = entNota.getId_nota();
                    fila[1] = entNota.getEntCarnet();
                    fila[2] = entNota.getEntNombre();
                    fila[3] = entNota.getEntApellido();
                    fila[4] = entNota.getEntCod_Materia();
                    fila[5] = entNota.getLab2();
                    fila[6] = entNota.getDiscusion2();
                    fila[7] = v.formatearDecimales(entNota.getProm2());
                    tabla.addRow(fila);
                }

                this.jtbleInsertarNotas.setModel(tabla);

                fila[0] = "Total alumnos";
                fila[1] = "";
                fila[2] = "";
                fila[3] = "";
                fila[4] = "";
                fila[5] = "";
                fila[6] = "";
                fila[7] = tabla.getRowCount();
                tabla.addRow(fila);

            } else {
                JOptionPane.showMessageDialog(rootPane, "No se recuperaron datos de la base de datos", "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(rootPane, ex.toString());
        }

    }
    
    
     public void cargarComboboxPlan() {
        
        ArrayList arryPlan = new ArrayList();
        pla = new Plan();
        arryPlan = pla.MostrarPlan();
        JList list_rad = new JList();
        DefaultListModel listModel_rad = new DefaultListModel();
        
        listModel_rad.addElement("Seleccione");
        if (arryPlan != null) {
            for (int i = 0; i < arryPlan.size(); i++) {
                entPla = (EntityPlan) arryPlan.get(i);
                listModel_rad.addElement(entPla.getNombre_plan());
            }
        } else {
            JOptionPane.showMessageDialog(rootPane, "No se recuperaron datos de la tabla Materia", "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);
        }
        list_rad.setModel(listModel_rad);

        //seteando dos combos con los planes

        this.jcmbPlan.setModel(new DefaultComboBoxModel(listModel_rad.toArray()));
        this.jcmbPlan.setSelectedIndex(0);
        
        this.jcmbPlan2.setModel(new DefaultComboBoxModel(listModel_rad.toArray()));
        this.jcmbPlan2.setSelectedIndex(0);
        
      
    }
    
      public void CargarComboBoxMateria(int id_plan) {
        //CARGANDO COMBOBOX DE MATERIAS
        ArrayList arryRad = new ArrayList();
       
        
        mate= new Materia();
        arryRad = mate.MostrarMateriasPlan_U1(id_plan);
        JList list_rad = new JList();
        DefaultListModel listModel_rad = new DefaultListModel();
        listModel_rad.addElement("Seleccione");
        if (arryRad != null) {
            for (int i = 0; i < arryRad.size(); i++) {
                entMate = (EntityMateria) arryRad.get(i);
                listModel_rad.addElement(entMate.getCodigo_asignatura());
            }
        } else {
            JOptionPane.showMessageDialog(rootPane, "No se recuperaron datos de la tabla Materia", "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);
        }
        list_rad.setModel(listModel_rad);
        this.jcmbMateria.setModel(new DefaultComboBoxModel(listModel_rad.toArray()));
        this.jcmbMateria.setSelectedIndex(0);
    }
      
      public void CargarComboBoxMateria2(int id_plan2) {
        //CARGANDO COMBOBOX DE MATERIAS
        ArrayList arryRad = new ArrayList();
       
        
        mate= new Materia();
        arryRad = mate.MostrarMateriasPlan_U1(id_plan2);
        JList list_rad = new JList();
        DefaultListModel listModel_rad = new DefaultListModel();
        listModel_rad.addElement("Seleccione");
        if (arryRad != null) {
            for (int i = 0; i < arryRad.size(); i++) {
                entMate = (EntityMateria) arryRad.get(i);
                listModel_rad.addElement(entMate.getCodigo_asignatura());
            }
        } else {
            JOptionPane.showMessageDialog(rootPane, "No se recuperaron datos de la tabla Materia", "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);
        }
        list_rad.setModel(listModel_rad);
        this.jcmbMateria2.setModel(new DefaultComboBoxModel(listModel_rad.toArray()));
        this.jcmbMateria2.setSelectedIndex(0);
    }

    public frmInsertarNotaIntroFisica2() {
        initComponents();
        this.setTitle("Registro de notas para Unidad 2");
        cargarComboboxPlan();
        BloquearControles();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        txtDis1 = new javax.swing.JTextField();
        txtLab1 = new javax.swing.JTextField();
        jlblDis1 = new javax.swing.JLabel();
        txtApellidos = new javax.swing.JTextField();
        jlblLab1 = new javax.swing.JLabel();
        txtNombres = new javax.swing.JTextField();
        jlblApellidos = new javax.swing.JLabel();
        txtInstructor = new javax.swing.JTextField();
        jlblNombres = new javax.swing.JLabel();
        jlblID = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        txtID = new javax.swing.JTextField();
        jbtnModificar = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jcmbPlan = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jcmbMateria = new javax.swing.JComboBox();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel2 = new javax.swing.JLabel();
        jcmbGrupo = new javax.swing.JComboBox();
        jlblSeleccionar = new javax.swing.JLabel();
        txtHorarioLab = new javax.swing.JTextField();
        jcmbPlan2 = new javax.swing.JComboBox();
        jbtnCargar = new javax.swing.JButton();
        jbtnBuscar = new javax.swing.JButton();
        jcmbMateria2 = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtbleInsertarNotas = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jbtnGenerartxt = new javax.swing.JButton();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);

        jlblDis1.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jlblDis1.setText("Discusión:");

        txtApellidos.setFont(new java.awt.Font("DejaVu Sans", 1, 12)); // NOI18N

        jlblLab1.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jlblLab1.setText("Laboratorio:");

        txtNombres.setFont(new java.awt.Font("DejaVu Sans", 1, 12)); // NOI18N

        jlblApellidos.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jlblApellidos.setText("Apellidos:");

        txtInstructor.setFont(new java.awt.Font("DejaVu Sans", 1, 12)); // NOI18N

        jlblNombres.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jlblNombres.setText("Nombres:");

        jlblID.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jlblID.setText("ID:");

        txtID.setFont(new java.awt.Font("DejaVu Sans", 1, 12)); // NOI18N

        jbtnModificar.setIcon(new javax.swing.ImageIcon("/home/mario/Dropbox/Sistema de laboratorio/Imagenes/agregar.jpg")); // NOI18N
        jbtnModificar.setText("Agregar nota");
        jbtnModificar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbtnModificarMouseClicked(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel3.setText("Plan 1:");

        jcmbPlan.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jcmbPlan.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcmbPlanItemStateChanged(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel4.setText("Materia 1:");

        jcmbMateria.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcmbMateriaItemStateChanged(evt);
            }
        });

        jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jLabel2.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel2.setText("Plan 2:");

        jcmbGrupo.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcmbGrupoItemStateChanged(evt);
            }
        });

        jlblSeleccionar.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jlblSeleccionar.setText("Seleccione un grupo de Laboratorio:");

        txtHorarioLab.setFont(new java.awt.Font("DejaVu Sans", 1, 12)); // NOI18N
        txtHorarioLab.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtHorarioLabActionPerformed(evt);
            }
        });

        jcmbPlan2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jcmbPlan2.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcmbPlan2ItemStateChanged(evt);
            }
        });

        jbtnCargar.setIcon(new javax.swing.ImageIcon("/home/mario/Dropbox/Sistema de laboratorio/Imagenes/cargar.png")); // NOI18N
        jbtnCargar.setText("Cargar");
        jbtnCargar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbtnCargarMouseClicked(evt);
            }
        });

        jbtnBuscar.setIcon(new javax.swing.ImageIcon("/home/mario/Dropbox/Sistema de laboratorio/Imagenes/buscar.png")); // NOI18N
        jbtnBuscar.setText("Buscar");
        jbtnBuscar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbtnBuscarMouseClicked(evt);
            }
        });

        jcmbMateria2.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcmbMateria2ItemStateChanged(evt);
            }
        });

        jLabel5.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel5.setText("Materia 2:");

        jtbleInsertarNotas.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jtbleInsertarNotas.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jScrollPane1.setViewportView(jtbleInsertarNotas);

        jLabel1.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel1.setText("Instructor:");

        jbtnGenerartxt.setIcon(new javax.swing.ImageIcon("/home/mario/Dropbox/Sistema de laboratorio/Imagenes/generartxt.jpg")); // NOI18N
        jbtnGenerartxt.setText("Generar txt");
        jbtnGenerartxt.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbtnGenerartxtMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(41, 41, 41)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(0, 1, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 968, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jbtnCargar)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jlblID)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(txtID, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jlblNombres)
                                        .addGap(18, 18, 18)
                                        .addComponent(txtNombres, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jlblApellidos)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtApellidos, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jbtnModificar, javax.swing.GroupLayout.Alignment.TRAILING))
                                .addGap(34, 34, 34)
                                .addComponent(jlblLab1)
                                .addGap(34, 34, 34)
                                .addComponent(txtLab1, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(45, 45, 45)
                                .addComponent(jlblDis1)
                                .addGap(18, 18, 18)
                                .addComponent(txtDis1, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(44, 44, 44)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jbtnBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jbtnGenerartxt, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(54, 54, 54))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(35, 35, 35)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jcmbMateria, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jcmbPlan, 0, 131, Short.MAX_VALUE))
                        .addGap(37, 37, 37)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel5))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jcmbPlan2, 0, 122, Short.MAX_VALUE)
                            .addComponent(jcmbMateria2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(35, 35, 35)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addGap(18, 18, 18)
                                .addComponent(txtInstructor, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jlblSeleccionar)
                                .addGap(46, 46, 46)
                                .addComponent(jcmbGrupo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtHorarioLab, javax.swing.GroupLayout.PREFERRED_SIZE, 285, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(102, 102, 102))))
            .addComponent(jSeparator1)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(jcmbPlan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2)
                            .addComponent(jcmbPlan2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(jcmbMateria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5)
                            .addComponent(jcmbMateria2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(26, 26, 26))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(22, 22, 22)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jlblSeleccionar)
                                    .addComponent(jcmbGrupo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtHorarioLab, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel1)
                                    .addComponent(txtInstructor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(230, 230, 230)
                        .addComponent(jbtnGenerartxt)
                        .addGap(18, 18, 18)
                        .addComponent(jbtnBuscar)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jlblNombres)
                            .addComponent(txtNombres, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jlblApellidos)
                            .addComponent(txtApellidos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jlblLab1)
                            .addComponent(txtLab1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jlblDis1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtDis1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jlblID)
                            .addComponent(txtID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(33, 33, 33)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbtnCargar)
                            .addComponent(jbtnModificar))
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 334, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(73, 73, 73))))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbtnModificarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnModificarMouseClicked
        // TODO add your handling code here:
        try {
            int id_nota = Integer.parseInt(this.txtID.getText());
            Double lab1 = Double.parseDouble(this.txtLab1.getText().trim());
            Double dis1 = Double.parseDouble(this.txtDis1.getText().trim());

            nota = new Nota();
            String msj = nota.SP_ModificarNotaUnidad2(id_nota, lab1, dis1);
            JOptionPane.showMessageDialog(rootPane, msj, "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);

            PopularTabla(id_grupo,id_materia,id_materia2);

        } catch (Exception ex) {
            System.out.println(ex.toString());
        }
    }//GEN-LAST:event_jbtnModificarMouseClicked

    private void jcmbPlanItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcmbPlanItemStateChanged
        ArrayList arryPlan = new ArrayList();

        pla = new Plan();
        arryPlan=pla.MostrarPlan();

        for (int i = 0; i < arryPlan.size(); i++) {
            entPla = (EntityPlan) arryPlan.get(i);
            if (this.jcmbPlan.getSelectedItem().equals(entPla.getNombre_plan())) {
                this.id_plan = entPla.getId_plan();
            }
        }

        CargarComboBoxMateria(id_plan);
    }//GEN-LAST:event_jcmbPlanItemStateChanged

    private void jcmbMateriaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcmbMateriaItemStateChanged
        ArrayList arryMateria = new ArrayList();

        mate = new Materia();
        arryMateria=mate.MostrarMateriasPlan_U1(id_plan);

        for (int i = 0; i < arryMateria.size(); i++) {
            entMate = (EntityMateria) arryMateria.get(i);
            if (this.jcmbMateria.getSelectedItem().equals(entMate.getCodigo_asignatura())) {
                this.id_materia = entMate.getId_materia();
            }
        }

        CargarComboBox(id_materia);
    }//GEN-LAST:event_jcmbMateriaItemStateChanged

    private void jcmbGrupoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcmbGrupoItemStateChanged
        // TODO add your handling code here:
        //        EntityGrupo entGrupo = new EntityGrupo();
        for (int i = 0; i < arry.size(); i++) {
            entHorLab = (EntityHorarioLab) arry.get(i);
            if (this.jcmbGrupo.getSelectedItem().equals(entHorLab.getEntGrupo())) {
                this.id_grupo = entHorLab.getEntGrupo();
            }
        }

        PopularTabla(id_grupo,id_materia,id_materia2);
        CargarInstructor(id_grupo,id_materia);
        CargarHorarioTxt(id_grupo,id_materia);
    }//GEN-LAST:event_jcmbGrupoItemStateChanged

    private void jcmbPlan2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcmbPlan2ItemStateChanged
        ArrayList arryPlan2 = new ArrayList();

        pla = new Plan();
        arryPlan2=pla.MostrarPlan();

        for (int i = 0; i < arryPlan2.size(); i++) {
            entPla = (EntityPlan) arryPlan2.get(i);
            if (this.jcmbPlan2.getSelectedItem().equals(entPla.getNombre_plan())) {
                this.id_plan2 = entPla.getId_plan();
            }
        }

        CargarComboBoxMateria2(id_plan2);
    }//GEN-LAST:event_jcmbPlan2ItemStateChanged

    private void jbtnCargarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnCargarMouseClicked
        // TODO add your handling code here:
        HabilitarControles();

        int fila = this.jtbleInsertarNotas.getSelectedRow();
        this.txtID.setText(String.valueOf(this.jtbleInsertarNotas.getValueAt(fila, 0)));
        this.txtNombres.setText(String.valueOf(this.jtbleInsertarNotas.getValueAt(fila, 2)));
        this.txtApellidos.setText(String.valueOf(this.jtbleInsertarNotas.getValueAt(fila, 3)));
        this.txtLab1.setText(String.valueOf(this.jtbleInsertarNotas.getValueAt(fila, 5)));
        this.txtDis1.setText(String.valueOf(this.jtbleInsertarNotas.getValueAt(fila, 6)));
    }//GEN-LAST:event_jbtnCargarMouseClicked

    private void jbtnBuscarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnBuscarMouseClicked
        // TODO add your handling code here:
        String titulo = (String) JOptionPane.showInputDialog(rootPane, "Ingrese el carnet, nombre o apellido a buscar", "Busqueda", JOptionPane.PLAIN_MESSAGE);
        Busqueda(titulo);
    }//GEN-LAST:event_jbtnBuscarMouseClicked

    private void jcmbMateria2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcmbMateria2ItemStateChanged
        ArrayList arryMateria2 = new ArrayList();

        mate = new Materia();
        arryMateria2=mate.MostrarMateriasPlan_U1(id_plan2);

        for (int i = 0; i < arryMateria2.size(); i++) {
            entMate = (EntityMateria) arryMateria2.get(i);
            if (this.jcmbMateria2.getSelectedItem().equals(entMate.getCodigo_asignatura())) {
                this.id_materia2 = entMate.getId_materia();
            }
        }

    }//GEN-LAST:event_jcmbMateria2ItemStateChanged

    private void jbtnGenerartxtMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnGenerartxtMouseClicked
        // TODO add your handling code here:
        String msj;
        msj = nota.generarTXT(this.arry_5);
        JOptionPane.showMessageDialog(rootPane, msj, "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_jbtnGenerartxtMouseClicked

    private void txtHorarioLabActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtHorarioLabActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtHorarioLabActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JButton jbtnBuscar;
    private javax.swing.JButton jbtnCargar;
    private javax.swing.JButton jbtnGenerartxt;
    private javax.swing.JButton jbtnModificar;
    private javax.swing.JComboBox jcmbGrupo;
    private javax.swing.JComboBox jcmbMateria;
    private javax.swing.JComboBox jcmbMateria2;
    private javax.swing.JComboBox jcmbPlan;
    private javax.swing.JComboBox jcmbPlan2;
    private javax.swing.JLabel jlblApellidos;
    private javax.swing.JLabel jlblDis1;
    private javax.swing.JLabel jlblID;
    private javax.swing.JLabel jlblLab1;
    private javax.swing.JLabel jlblNombres;
    private javax.swing.JLabel jlblSeleccionar;
    private javax.swing.JTable jtbleInsertarNotas;
    private javax.swing.JTextField txtApellidos;
    private javax.swing.JTextField txtDis1;
    private javax.swing.JTextField txtHorarioLab;
    private javax.swing.JTextField txtID;
    private javax.swing.JTextField txtInstructor;
    private javax.swing.JTextField txtLab1;
    private javax.swing.JTextField txtNombres;
    // End of variables declaration//GEN-END:variables
}
